/** @file AvatarController.h
    @class AvatarController
    @brief Controlls a PlayerAvatar
*/
#include "stdafx.h"
#include "PlayerAvatar.h"
#include "Input.h"
#include "Controller.h"
#include <list>
#include "Command.h"
#include "DataPacker.h"
#include "InputObserver.h"
#include "NetworkController.h"
#include "Player.h"

#ifndef __AvatarController_h_
#define __AvatarController_h_

class Player;

class AvatarController : public Controller, public InputObserver {
public:
	/**
	* The constructor
	*/
	AvatarController(NetworkController* nc);
	
	/**
	* The destructor
	*/
	~AvatarController();
	
	/**
	* @brief Sets the player avatar
	*/
	void setPlayerAvatar(PlayerAvatar* avatar);
	
	/**
	* @brief Returns the player avatar
	*/
	PlayerAvatar* getPlayerAvatar();

	/**
	* @brief Logic update loop, called every frame
	*/
	virtual bool update(float deltaTime);
	
	/**
	* @brief Sets if this controller is active
	*/
	virtual void setActive(bool in);
	
	/**
	* @brief Sets the player this controller belongs to
	*/
	void setPlayer(Player* p);
	
	/**
	* @brief What happens when a key is pressed
	*/
	bool keyPressed(const OIS::KeyEvent &arg);
	
	/**
	* @brief What happens when a key is released
	*/
	bool keyReleased(const OIS::KeyEvent &arg);
	
	/**
	* @brief What happens when the mouse is moved
	*/
	bool mouseMoved( const OIS::MouseEvent &arg );
	
	/**
	* @brief What happens when a mouse button is pressed
	*/
	bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
	
	/**
	* @brief What happens when a mouse button is released 
	*/
	bool mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id );

	/**
	* @brief Returns the internal command list
	*/
	list<Command*>* getCommands();
	
private:
	/**
	* @brief The player avatar belonging to this controller
	*/
	PlayerAvatar *m_playerAvatar;
	
	/**
	* @brief THe internal command list
	*/
	std::list<Command*> m_commands;
	
	/**
	* @brief The player this controller belongs to
	*/
	Player* player;
	
	float m_lastDeltaAngle;
	float m_lastMouseX;
	float m_lastMouseY;
};

#endif //__Input_h_